<?php
session_start();
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
    header("Location: ../login.php");
    exit();
}

require '../config.php';

$user_id = $_GET['id'];

// 删除用户
$stmt = $conn->prepare("DELETE FROM users WHERE id = ?");
$stmt->bind_param("i", $user_id);

if ($stmt->execute()) {
    header("Location: manage_users.php");
    exit();
} else {
    echo "<p class='error'>删除用户失败，请重试</p>";
}

$stmt->close();
$conn->close();
?>